<template>
    <div class="mine">
        <!-- 顶部导航 -->
        <van-nav-bar title="我的" />

        <!-- 页面要渲染这四个数据 -->
        <van-row>
            <van-col span="6">
                <p>本金已返</p>
                <p>{{ sum_return_benjin }}</p>
            </van-col>
            <van-col span="6"
                ><p>本金未返</p>
                <p>{{ sum_no_return_benjin }}</p></van-col
            >
            <van-col span="6"
                ><p>佣金已返</p>
                <p>{{ sum_return_yongjin }}</p></van-col
            >
            <van-col span="6"
                ><p>佣金未返</p>
                <p>{{ sum_no_return_yongjin }}</p></van-col
            >
        </van-row>
    </div>
</template>

<script>
export default {
    mounted() {
        this.getList();
    },
    data() {
        return {
            sum_return_benjin: 0,
            sum_no_return_benjin: 0,
            sum_return_yongjin: 0,
            sum_no_return_yongjin: 0,
        };
    },
    methods: {
        async getList() {
            const res = await this.$http.get('/memos');
            res.data.forEach((item) => {
                console.log(item);
                // 本金未返
                if (item.is_return_benjin === 0) {
                    this.sum_no_return_benjin += item.benjin;
                    // 本金已返
                } else {
                    this.sum_return_benjin += item.benjin;
                }

                // 佣金未返
                if (item.is_return_yongjin === 0) {
                    this.sum_no_return_yongjin += item.yongjin;
                    // 佣金已返
                } else {
                    this.sum_return_yongjin += item.yongjin;
                }
            });
        },
    },
};
</script>

<style lang="less" scoped></style>
